package bomberman.runable;

import bomberman.model.Enemy;
import bomberman.model.Flame;
import bomberman.swing.BomJPanel;
import bomberman.util.CommonTouch;


/**
 * 火焰生产直到消失期间，一直检测火焰和敌人的碰撞
 * @author EX-FUHUICHAO001
 * 2016年9月26日15:15:30
 */
public class MyRunableFlameTouchEnemy implements Runnable {
	
	private Flame flame;
	
	public MyRunableFlameTouchEnemy(Flame flame){
		this.flame = flame;
	}
	
	
	public void run() {
		while(!flame.isRemove()){
			for(Enemy enemy : BomJPanel.enemys){
				// 若火焰和敌人碰撞，移除敌人(!flame.isRemove()每次判断，避免火焰消失后还在继续本次循环)
				if(!flame.isRemove() && enemy.isLive() && CommonTouch.checkIfFlameTouchEnemy(flame, enemy)){
					enemy.remove();
				}
			}
		}
	}


	public Flame getFlame() {
		return flame;
	}


	public void setFlame(Flame flame) {
		this.flame = flame;
	}
	
	
	
}
